﻿<%@ Page Language="C#" %>


<!DOCTYPE html>
<script runat="server">

    static CommonLib.DbHelper.IDBhelper dbHelper = new CommonLib.DbHelper.Factory().IDBhelper;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBind_data();
        }
    }

    private void DataBind_data()
    {
        var sdr = dbHelper.ExecuteReader("SELECT * FROM " + Request["tn"].ToString() + " WHERE ID = '" + Request["id"].ToString() + "'");
        if (sdr.Read())
        {
            名称TextBox.Text = sdr["Name"].ToString();
            内容TextBox.Text = sdr["Contents"].ToString();
            地址TextBox.Text = sdr["Url"].ToString();
        }
        sdr.Close();
    }

    private void setDropDownList(DropDownList list, string value, string defaultValue)
    {
        try
        {
            list.Items.FindByValue(value).Selected = true;
        }
        catch
        {
            list.Items.FindByValue(defaultValue).Selected = true;
        }
    }

    protected void 重置Button_Click(object sender, EventArgs e)
    {
        DataBind_data();
    }

    protected void 提交Button_Click(object sender, EventArgs e)
    {
        SqlParameter[] P = {
                new SqlParameter("@ID", Request["id"].ToString()),
                new SqlParameter("@Name", 名称TextBox.Text),
                new SqlParameter("@Contents", 内容TextBox.Text),
                new SqlParameter("@Url", 地址TextBox.Text)
            };
        dbHelper.ExecuteNonQuery(@"UPDATE " + Request["tn"].ToString() + " SET Name=@Name,Contents=@Contents,Url=@Url WHERE (ID = @ID)", P);

        //更新父级页面节点名称
        JSLiteral.Text = "<script>";
        JSLiteral.Text += "var node = parent.$(\"#tree\", window.parent.document).tree(\"find\", \"" + Request["id"].ToString() + "\");";
        JSLiteral.Text += "node.text = \"" + 名称TextBox.Text + "\";";
        JSLiteral.Text += "parent.$(\"#tree\", window.parent.document).tree(\"update\", node);";
        JSLiteral.Text += "</" + "script>";

        DataBind_data();
    }
</script>


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>树属性管理</title>

    <link href="/Themes/css/treeIcons.css" rel="stylesheet" />
    <link href="/Js/plugin/editormd/css/editormd.css" rel="stylesheet" />
    <script type="text/javascript" src="/Js/jquery.min.js"></script>
    <script type="text/javascript" src="/Js/plugin/editormd/editormd.min.js"></script>
    <style type="text/css">
        td { padding: 3px; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <table width="100%" style="font-size: 12px;" cellpadding="0" cellspacing="0">
            <tr>
                <td width="100px" align="right">名称：</td>
                <td>
                    <asp:TextBox ID="名称TextBox" runat="server" Width="400px" /></td>
            </tr>
            <tr>
                <td width="100px" align="right">地址：</td>
                <td>
                    <asp:TextBox ID="地址TextBox" runat="server" Width="600px" /></td>
            </tr>
            <tr>
                <td width="100px" align="right"></td>
                <td>
                    <asp:Button ID="提交Button" runat="server" Text="提 交" OnClick="提交Button_Click" /></td>
            </tr>
            <tr style="display: none;">
                <td>
                    <div id="test-editormd">
                        <asp:TextBox ID="内容TextBox" runat="server" CssClass="input" TextMode="MultiLine" />
                    </div>
                </td>
            </tr>
        </table>
        <asp:Literal ID="JSLiteral" runat="server" />
    </form>
</body>
</html>
<script type="text/javascript">
    function xz(value) {
        $("#图标TextBox").val(value);
    }
</script>
<script type="text/javascript">
    var testEditor;
    $(function () {
        testEditor = editormd({
            syncScrolling: "single",

            id: "test-editormd",
            //width: "100%",
            height: 850,
            path: '/Js/plugin/editormd/lib/',
            theme: "dark",
            //previewTheme: "dark",
            //editorTheme: "pastel-on-dark",
            //markdown: md,
            codeFold: true,
            //syncScrolling : false,
            saveHTMLToTextarea: true,    // 保存 HTML 到 Textarea
            searchReplace: true,
            //watch : false,                // 关闭实时预览
            htmlDecode: "style,script,iframe|on*",            // 开启 HTML 标签解析，为了安全性，默认不开启
            //toolbar  : false,             //关闭工具栏
            //previewCodeHighlight : false, // 关闭预览 HTML 的代码块高亮，默认开启
            emoji: true,
            taskList: true,
            tocm: true,         // Using [TOCM]
            tex: true,                   // 开启科学公式TeX语言支持，默认关闭
            flowChart: true,             // 开启流程图支持，默认关闭
            sequenceDiagram: true,       // 开启时序/序列图支持，默认关闭,
            //dialogLockScreen : false,   // 设置弹出层对话框不锁屏，全局通用，默认为true
            //dialogShowMask : false,     // 设置弹出层对话框显示透明遮罩层，全局通用，默认为true
            //dialogDraggable : false,    // 设置弹出层对话框不可拖动，全局通用，默认为true
            //dialogMaskOpacity : 0.4,    // 设置透明遮罩层的透明度，全局通用，默认值为0.1
            //dialogMaskBgColor : "#000", // 设置透明遮罩层的背景颜色，全局通用，默认为#fff
        });
    });
</script>
